package cn.edu.sjtu.se.dslab.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import cn.edu.sjtu.se.dslab.dao.IBaseDao;
import cn.edu.sjtu.se.dslab.dao.IPGroupDao;
import cn.edu.sjtu.se.dslab.project.PGroup;


@Repository("pgroupDao")
public class PGroupDaoImpl implements IPGroupDao {
	
	@Resource(name = "baseDao")
	private IBaseDao<PGroup> baseDao;
	
	@Override
	public PGroup queryById(long id) {
		return baseDao.queryById(PGroup.class, id);
	}

	@Override
	public void save(PGroup pgroup) {
		baseDao.save(pgroup);
	}

	@Override
	public PGroup update(PGroup pgroup) {
		return baseDao.update(pgroup);
	}

	@Override
	public List<PGroup> queryByList() {
		//the name of the class, the first letter must be uppercase
		return baseDao.queryList("PGroup");
	}
	
	@Override
	public List<PGroup> queryValidPGroups() {
		StringBuffer hql = new StringBuffer();
		hql.append("from PGroup where deleted =0");
		return baseDao.query(hql.toString());
	}

}
